{% extends "layout/content.twig" %}

{% block main %}
    <style>
        .error-page {
            width: 100%;
            text-align: center;
            background: white;
        }

        .text {
            font: 400 5vmin "Courgette";
            padding: 30px 0;
        }

        .number {
            background: #fff;
            position: relative;
            font: 900 30vmin "Consolas";
            letter-spacing: 5vmin;
            text-shadow: 2px -1px 0 #000, 4px -2px 0 #0a0a0a, 6px -3px 0 #0f0f0f, 8px -4px 0 #141414, 10px -5px 0 #1a1a1a, 12px -6px 0 #1f1f1f, 14px -7px 0 #242424, 16px -8px 0 #292929;
        }

        .number::before {
            background-color: #673ab7;
            background-image: radial-gradient(closest-side at 50% 50%, #ffc107 100%, rgba(0, 0, 0, 0)), radial-gradient(closest-side at 50% 50%, #e91e63 100%, rgba(0, 0, 0, 0));
            background-repeat: repeat-x;
            background-size: 40vmin 40vmin;
            background-position: -100vmin 20vmin, 100vmin -25vmin;
            width: 100%;
            height: 100%;
            mix-blend-mode: screen;
            -webkit-animation: moving 10s linear infinite both;
            animation: moving 10s linear infinite both;
            display: block;
            position: absolute;
            content: "";
        }

        @-webkit-keyframes moving {
            to {
                background-position: 100vmin 20vmin, -100vmin -25vmin;
            }
        }

        @keyframes moving {
            to {
                background-position: 100vmin 20vmin, -100vmin -25vmin;
            }
        }
    </style>
    <div class="error-page">
        <div class="number">3003</div>
        <div class="text">
            <div>{{ __('permission.no_permission') }}</div>
            {% if title %}
                <div class="layui-word-aux layui-font-14 mt20">
                    {{ __('permission.apply_rule_title') }}： {{ title }}
                </div>
            {% endif %}
            <div class="layui-word-aux layui-font-14">
                {{ __('permission.apply_rule_url') }}： {{ url }}
            </div>
            <div class="layui-font-14 mt30">
                <a href="javascript:;" class="layui-word-aux" id="permissionApply">
                    {{ __('permission.is_apply') }} {{ __('permission.apply_text') }}
                </a>
            </div>
        </div>
    </div>
{% endblock %}

{% block script %}
    <script type="text/javascript">
        layui.use(['layer', 'http', 'toast'], function () {
            let layer = layui.layer;
            let http = layui.http;
            let toast = layui.toast;

            let title = '{{ title }}';
            let url = '{{ url }}';

            $('#permissionApply').on('click', function () {

                let _index = layer.prompt(
                  {
                      title: '{{ __('permission.please_input_intro') }}',
                      formType: 2,
                      offset: '100px'
                  },
                  function (value, index, elem) {
                      if (value === '') {
                          toast.top('{{ __('permission.apply_intro_not_null') }}');
                          return elem.focus();
                      }
                      http.post('{{ auth_route('home/ruleApply') }}', {
                          title: title,
                          url: url,
                          remark: value
                      }).then(res => {

                          layer.close(_index);
                          let data = res.data || '';

                          if (data) {
                              let status = data.status || 0;
                              if (status === 1) {
                                  toast.top('{{ __('rule.apply_passed_tip') }}', 1);
                              } else if (status === -1) {
                                  toast.error('{{ __('rule.apply_refused_tip') }} :' + data.reason);
                              } else {
                                  toast.top(res);
                              }
                          } else {
                              toast.top(res);
                          }
                      });
                  });

            });
        });
    </script>
{% endblock %}